<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>图集查看器</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="./js/jquery.min.js"></script>
    <script src="./js/pako.min.js"></script>
    <link rel="stylesheet" href="./css/layui.css" media="all">
</head>
<body>
<div class="layui-container">
    <div class="layui-row" id="main">

    </div>
</div>
<script src="./js/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    let str = decode(getQueryString('d'));
    if (str === null) {
        $("#main").text("数据读取失败")
    } else {
        let list = eval('(' + str + ')');
        list = list.def.map(i => list.sameH + i + list.sameT);
        $('#demo').text(decode(getQueryString('d')));
        layui.use('flow', () => layui.flow.load({
            elem: '#main',
            done: (page, next) => {
                next(`<img class="layui-col-xs12" alt="丢图" src="${list[page % list.length]}" num="${page}">`, page < list.length)
            }
        }));
    }

    function getQueryString(name) {
        let r = window.location.search.substr(1).match(new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"));
        return r != null ? unescape(r[2]) : null;
    }

    function decode(encodedData) {
        return encodedData === null ? null :
            String.fromCharCode.apply(null, new Uint16Array(pako.inflate(
                new Uint8Array(window.atob(encodedData).split('').map(x => x.charCodeAt(0))))));
    }
</script>
</body>
</html>
